package com.hellobike.haxing.modules.wms.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.hellobike.haxing.modules.wms.dto.OrderDetailDto;
import com.hellobike.haxing.modules.wms.dto.OrderHeaderDto;
import com.hellobike.haxing.modules.wms.entity.DeliveryOrderHeader;
import com.hellobike.haxing.modules.wms.mapper.DeliveryOrderHeaderMapper;
import com.hellobike.haxing.modules.wms.service.IDeliveryOrderHeaderService;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @Description: t_wms_delivery_order_header
 * @Author: haxing-boot
 * @Date:   2020-01-14
 * @Version: V1.0
 */
@Service
public class DeliveryOrderHeaderServiceImpl extends ServiceImpl<DeliveryOrderHeaderMapper, DeliveryOrderHeader> implements IDeliveryOrderHeaderService {

    @Override
    public List<DeliveryOrderHeader> getByWaveId(Long waveId) {
        DeliveryOrderHeader q = new DeliveryOrderHeader();
        q.setWaveId(waveId);
        QueryWrapper<DeliveryOrderHeader> queryWrapper = new QueryWrapper<>(q);
        return baseMapper.selectList(queryWrapper);
    }

    @Override
    public DeliveryOrderHeader getByOrderCode(String orderCode,Long warehouseId) {
        DeliveryOrderHeader q = new DeliveryOrderHeader();
        q.setOrderCode(orderCode);
        q.setWarehouseId(warehouseId);
        QueryWrapper<DeliveryOrderHeader> queryWrapper = new QueryWrapper<>(q);
        return baseMapper.selectOne(queryWrapper);
    }

    @Override
    public List<OrderHeaderDto> getUnSyncOrders() {
        return baseMapper.getUnSyncOrders();
    }

    @Override
    public List<OrderDetailDto> getOrderDetailByOrderId(Long orderId) {
        return baseMapper.getOrderDetailByOrderId(orderId);
    }

    @Override
    public void updateSyncOrder(Long id) {
        baseMapper.updateSyncOrder(id);
    }
}
